def max_substring(s):
    chs = []
    for ch in enumerate(s):
        if ch[1] not in chs:
            chs.append(ch)
        else:
            if ch in chs:
               index = chs.index(ch)
               chs.append(ch[1])
               for e in range(index+1):
                   chs.pop(e)
    return chs
def main():
    a = "arabcacfr"
    print(max_substring(a))
if __name__ == "__main__":
    main()

            